<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>例子1-JS进阶总结</title>
    </head>
    <body>
        <pre>
            <code>
                // 闭包对内存的占用和释放

                function a()
                {
                    var largeStr = {
                        str: new Array(100000).join('x')
                    }
                    function b() {
                        return largeStr
                    }

                    largeStr.b = b

                    return b
                }

                var foo = a()
                foo()

                setTimeout(function() {
                    foo = null;
                }, 5000);
            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/1.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>
</html>